<!-- revieworder 页面内容 -->
<section class="revieworder" ng-controller="revieworderCtrl">
    <ol class="breadcrumb">
        <li ng-click="goBack();"><a>待审核订单</a></li>
        <li><a>订单详情</a></li>
    </ol>
    <nav class="navbar navbar-default nav-state-bar yf-shadow" ng-if='order.workflow_state != "canceled"'>
        <p class="navbar-text">订单状态</p>
        <ul class="nav navbar-nav">
            <li ng-repeat="arr in statesArrs track by $index" ng-class="{'done': arrindex >= $index }">
                <a>
                    <div class="circle"></div>
                    {{ arr.name }}
                </a>
            </li>
        </ul>
    </nav>
    <div class="panel panel-default yf-shadow">
        <div class="panel-body">
            <div class="row">
                <div class="col col-md-7 col-sm-7 col-xs-7 order-detail">
                    <div class="row order-detail-info">
                        <div class="line">订单号: {{ order.serial_number }}</div>
                        <div class="line" ng-if='!order.mount_order'>预约测量时间: {{ order.booking_date * 1000 | date: 'yyyy-MM-dd HH:mm '}}</div>
                        <div class="line" ng-if='order.mount_order'>预约安装时间: {{ order.install_date * 1000 | date: 'yyyy-MM-dd HH:mm '}}</div>
                        <div class="line">姓名: {{ order.name }}</div>
                        <div class="line">预估面积: {{order.square}}(㎡) | 品牌: {{order.company_name}}</div>
                        <div class="line address">
                            地址:
                            <a ng-class="{'dis': user_role != 2}" ng-click="goMap(user_role, order.id);">
                                <span class="glyphicon glyphicon-map-marker"></span> {{ order.address }}
                            </a>
                        </div>
                    </div>
                    <div class="row order-detail-state">
                        <div class="line">安装总价: <span class="money" ng-if='order.total'>{{ order.total | moneyint }}元</span></div>
                        <div class="line">订单状态: {{ order.workflow_state | state }}</div>
                        <div class="line">服务商: {{ order.service_info.name }}
                          <div class="pull-right" style="padding-right: 20px;" ng-show="(order.workflow_state == 'appointed_installation') || (order.workflow_state == 'measured')">
                            <a style="color: #58c676;" ng-click="changeOrderByRole(order.id, user);" ng-if="handleLists.order.indexOf(user.user_type) != -1">修改订单</a>
                          </div>
                          <div class="pull-right" style="padding-right: 20px;" ng-show="order.workflow_state == 'installed' || order.workflow_state == 'confirm_installed'">
                              <a style="color: #58c676;" ng-click="changeOrderByRole(order.id, user);" ng-if="handleLists.order.indexOf(user.user_type) != -1 && !order.manager_confirm">修改订单</a>
                          </div>
                        </div>
                    </div>
                </div>
                <!-- 服务商接单界面 -->
                <div class="col col-md-5 col-sm-5 col-xs-5">
                    <!-- 已测量 -->
                    <div ng-if="order.workflow_state == 'measured'">
                        <h4 class="line-title">最新进程</h4>
                        <div class="line time">{{ order.updated_at * 1000 | date: 'yyyy-MM-dd HH:mm'}}</div>
                        <div class="line"><span class="name">{{ order.service_info.name }}</span>上传了{{ order.measure_pictures[0].length }}张测量文件</div>
                        <div class="line">等待审核</div>
                        <div class="line time">{{order.measure_pictures[0][0].updated_at * 1000 | date: 'yyyy-MM-dd HH:mm'}}上传的测量图片</div>
                        <div class="line">
                            <ul class='previewpicturelist'>
                                <li ng-repeat='(kp, pic) in order.measure_pictures[0] track by kp' ng-click="downloadPdf(pic.image.url);">
                                    <img ng-src="{{ pic.image.url | to_url }}" data-action="zoom">
                                </li>
                            </ul>
                        </div>
                        <div class="line" ng-if='user_role == 1' style="margin-bottom: 20px;">
                            <!-- <button class='btn btn-default yf-btn' ng-click="changeOrderByRole(order.id, user);" ng-if="handleLists.order.indexOf(user.user_type) != -1">修改订单</button> -->
                            <button class='btn btn-default yf-btn' ng-click="confirmOrder();">审核通过</button>
                        </div>
                        <!-- <div ng-if='order.flows && order.flows.length > 0'>
                            <div class="line">
                                留言
                            </div>
                            <div class="line" style='padding-left: 5px;padding-right: 5px;' ng-repeat="flow in order.flows track by $index">
                                {{ flow.created_at * 1000 | date: 'yyyy-MM-dd HH:mm' }}
                                {{ flow.user_name }}:
                                {{ flow.content }}
                            </div>
                        </div>
                        <div>
                            <div class="line">
                                <input type="text" name="content" ng-model='content'>
                            </div>
                            <div class="line text-right"  style="padding-right: 10px;margin-bottom: 10px;">
                                <button class="btn btn-default yf-btn" ng-click="sendContent(order.id, content);content=''">确认</button>
                            </div>
                        </div> -->
                        <!-- <div class="line">
                            您可以
                            <a href="javascript:void(0);" ng-click="deleteOrder(order.id);">取消订单</a>
                        </div> -->
                    </div>
                    <!-- 预约安装 -->
                    <div ng-show="order.workflow_state == 'appointed_installation'">
                        <h4 class="line-title">最新进程</h4>
                        <div ng-if="user_role != 2">
                            <!-- <div class="line time">{{ order.install_date * 1000 | date: 'yyyy-MM-dd HH:mm'}}</div> -->
                            <div class="line" ng-if='order.install_date'>
                                等待服务商安装
                            </div>
                            <div class="line" ng-if='!order.install_date'>
                                等待服务商确认安装时间
                            </div>
                        </div>
                        <div ng-show="user_role == 1 || handleLists.order.indexOf(user.user_type) != -1">
                            <div class="line time">指派安装师傅:</div>
                            <div class="line">
                                <input type="text" class='form-control' ng-value="order.service_info.name" data-toggle="modal" data-target="#servermodal" name="">
                                <!-- <p class="form-control-static" data-toggle="modal" data-target=".servermodal">{{order.service_info.name}}</p> -->
                            </div>
                            <!-- <div class="line" ng-if='user_role == 2'>
                                <a class='btn yf-btn' data-toggle="modal" data-target=".servermodal">选择安装师傅</a>
                            </div> -->
                            <div class="line" ng-if='!setisinstalltime'>
                                <a ng-click="updateTimeAndMaster(false, order);" class="btn btn-default btn-upload  yf-btn"> 确定 </a>
                            </div>
                            <div class="line" ng-if='user_role == 1'>
                                <!-- <button class='btn btn-default yf-btn' ng-click="changeOrderByRole(order.id, user);" ng-if="handleLists.order.indexOf(user.user_type) != -1">修改订单</button> -->
                            </div>
                        </div>
                    </div>
                    <!-- 已安装 -->
                    <div ng-show="order.workflow_state == 'installed' || order.workflow_state == 'confirm_installed'">
                        <h4 class="line-title">最新进程</h4>
                        <div class="line"><img class="img-circle" ng-src="{{ order.service_info.image }}" data-action="zoom" alt=""></div>
                        <div class="line time">{{ order.updated_at * 1000 | date: 'yyyy-MM-dd HH:mm'}}</div>
                        <div class="line">
                            安装完成，等待付款
                        </div>
                        <!-- <div class="line"> -->
                            <!-- <button class='btn btn-default yf-btn' ng-click="changeOrderByRole(order.id, user);" ng-if="handleLists.order.indexOf(user.user_type) != -1 && !order.manager_confirm">修改订单</button> -->
                        <!-- </div> -->
                        <div ng-if='order.is_company && order.workflow_state == "confirm_installed"'>
                            <div class="line" ng-if="!order.manager_confirm && ['manager'].indexOf(user.user_type) != -1">
                                <button class='btn btn-default yf-btn' ng-click="corfirmInstall(order.id);">确认安装</button>
                            </div>
                            <div class="line" ng-if="order.manager_confirm && ['finance'].indexOf(user.user_type) != -1">
                                <button class='btn btn-default yf-btn' data-toggle="modal" data-target=".pay-modal-sm">直接支付</button>
                            </div>
                        </div>
                    </div>
                    <!-- 已完成 -->
                    <div ng-show="order.workflow_state == 'completed'">
                        <h4 class="line-title">最新进程</h4>
                        <div class="line time">{{ order.updated_at * 1000 | date: 'yyyy-MM-dd HH:mm'}}</div>
                        <div class="line" ng-if='user_role != 0 || handleLists.all.indexOf(user.user_type) != -1'>
                            订单已经完成
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel-footer">
            <div class="row margin-reset comment-box">
                <h3>留言区</h3>
                <form role="form" ng-if="order.workflow_state == 'measured'">
                    <div class="input-group">
                        <input type="text" class="form-control comment-input" ng-model='content' ng-enter="sendContent(order.id, content);content=''">
                        <span class="input-group-btn">
                          <button class="btn btn-default comment-btn" type="button" ng-click="sendContent(order.id, content);content=''">留言</button>
                        </span>
                    </div>
                </form>
            </div>
            <div class="row margin-reset comment-list">
                <div class="comment-item" ng-repeat="flow in order.flows track by $index">
                    <p class="name">{{ flow.user_name }}</p>
                    <p class="content">{{ flow.content }}</p>
                    <p class="time">{{ flow.created_at * 1000 | date: 'yyyy-MM-dd HH:mm' }}</p>
                </div>
            </div>
        </div>
    </div>
    <div journal order='order'></div>

    <div class="modal fade pay-modal-sm" id='payModal' tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm modal-edit">
            <div class="modal-content">
                <div class="modal-head">
                    订单支付
                </div>
                <form name='payorderform' role="form">
                    <div class="form-group form-group-line">
                        <div class="row margin-reset">
                            <div class="col-xs-8 padding-reset text-left">服务商：{{ order.service_info.name}}</div>
                            <div class="col-xs-4 text-right state">需支付</div>
                        </div>
                        <div class="row margin-reset">
                            <!-- <div class="col-xs-8 padding-reset text-left">高{{ order.width }}(cm)/宽{{ order.height }}(cm)/{{ order.company_name }}</div> -->
                            <div class="col-xs-8 padding-reset text-left">预估面积{{ order.square }}(㎡)/{{ order.company_name }}</div>
                            <div class="col-xs-4 padding-reset text-right">￥<span class="money1">{{ order.total | moneyint }}</span></div>
                        </div>
                    </div>
                    <div class="form-group form-group-line">
                        <div class="row margin-reset">
                            <div class="col-xs-5 padding-reset text-left">账户余额</div>
                            <div class="col-xs-7 padding-reset text-right">￥<span class="money2">{{ user.amount | moneyint: true }}</span></div>
                        </div>
                    </div>
                    <!-- <div class="form-group">
                            <label for="tel">支付密码</label>
                            <input type="tel" class="form-control" ng-model='order.tel' id="tel" placeholder="联系电话" required>
                        </div> -->
                    <div class="row">
                        <div class="text-center">
                            <button type="submit" class="btn btn-default btn-submit yf-btn" ng-disabled="payorderform.$invalid" ng-click="payOrder(order);">立即付款</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="modal fade common-modal" id="servermodal" tabindex="-1" role="dialog" aria-labelledby="common-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content yf-shadow">
                <div class="modal-header text-center">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title" id="common-modal">
                          指定服务商
                    </h3>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-offset-1 col-lg-10 col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-12">
                          <form role="form" class="search-input-group">
                              <div class="input-group">
                                  <input type="search" class="form-control mt_input" ng-model='keyword' ng-enter="getMaster(keyword);" placeholder="输入师傅的账号或姓名">
                                  <span class="input-group-btn">
                                      <button class="btn mt_group_btn" type="button" ng-click="getMaster(keyword);">搜索</button>
                                  </span>
                              </div>
                          </form>
                        </div>
                        <div class="col-lg-offset-1 col-lg-10 col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-12" ng-show='noperson' ng-bind='noperson' style="color: red;">
                        </div>
                        <div class="col-lg-offset-1 col-lg-10 col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-12">
                          <table class="table table-striped table-bordered table-condensed">
                              <thead ng-if="masters">
                                  <th>账号</th>
                                  <th>姓名</th>
                              </thead>
                              <tr ng-repeat="master in masters track by $index">
                                  <td ng-click="setMaster(master);">{{master.tel}}</td>
                                  <td ng-click="setMaster(master);">{{master.real_name}}</td>
                              </tr>
                          </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
